package com.qfedu.mtl.service.impl;

import com.qfedu.mtl.dao.CommentDao;
import com.qfedu.mtl.dao.impl.CommentDaoImpl;
import com.qfedu.mtl.entity.Comments;
import com.qfedu.mtl.query.CommentQuery;
import com.qfedu.mtl.service.CommentService;
import com.qfedu.mtl.util.page.Pager;

import java.util.List;

public class CommentServiceImpl implements CommentService {

    CommentDao dao = new CommentDaoImpl();

    @Override
    public Pager<Comments> findPage(Integer page, Integer size, CommentQuery query) {
        List<Comments> list = dao.selectData(page, size, query);
        Integer total = dao.selectTotal(query);
        Pager<Comments> pager = new Pager<>(list, page, size,total);
        return pager;
    }

    @Override
    public void save(Comments com) {
        dao.insert(com);
    }

    @Override
    public Comments delete(Integer id) {
        dao.delete(id);
        return null;
    }

    @Override
    public void deleteBatch(List<Integer> ids) {
        dao.deleteBatch(ids);
    }

    @Override
    public void update(Comments com) {
        dao.update(com);
    }

    @Override
    public Comments findById(Integer id) {
        return dao.findById(id);
    }
}
